-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Web Bluetooth] Add Read descriptors sample #478
[Web Bluetooth] Add Read descriptors sample #478
Conversation
2349fb1
to
0802f6b
Compare
await descriptor.readValue().then(value => { | ||
log('> Client Characteristic Configuration:'); | ||
log(' > Notifications: ' + (value.getUint8(0) ? 'ON' : 'OFF')); | ||
log(' > Indications: ' + (value.getUint8(1) ? 'ON' : 'OFF')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fetching the 2nd byte, but you intended to select the 2nd bit. Use something like:
value.getUint8(0) & 0b01 // notifications
value.getUint8(0) & 0b10 // indications
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rookie mistake. Thanks for catching this @scheib
ES6 binary notation to the rescue!
@scheib WDYT? |
For info, I've just submitted a PR at rouge-ruby/rouge#619 to make ES6 Binary literals and Octal literals highlighting works. |
Links giving me nothing but 404 pages someone give me a BLE Bluetooth link or download access please |
You can find all samples at https://googlechrome.github.io/samples/web-bluetooth/index.html |
* [Web Bluetooth] Add Read descriptors sample * Fix byte/bit mistake
Here's a more advanced sample for reading Bluetooth GATT descriptors.
R: @scheib
You can try it live at:
https://beaufortfrancois.github.io/samples/web-bluetooth/read-descriptors.html
https://beaufortfrancois.github.io/samples/web-bluetooth/read-descriptors-async-await.html
https://beaufortfrancois.github.io/samples/web-bluetooth/index.html